# 家具类: 名称，占地
class Furniture(object):
    def __init__(self,name,area) -> None:
        self.name = name
        self.area = area
    def __str__(self) -> str:
        # 初始化信息
        return '家具的名称为[%s],占地面积[%d]平方米'%(self.name,self.area)
        
# 房子类: 名称，占地
class House(object):
    def __init__(self,name,area) -> None:
        self.name = name
        self.area = area
        self.furniture_list = []
        self.free_area = area
        # 剩余面积

    def add_furniture(self,obj_fur):
        '''添加家具'''
        if self.free_area > obj_fur.area:
            self.furniture_list.append(obj_fur)
            self.free_area -= obj_fur.area
            print('空间充足，家具[%s]添加成功'%obj_fur.name)
        else:
            print('加油吧，骚年，买个大房子！')
    def __str__(self) -> str:
        for i in self.furniture_list:
            print('目前家中有家具[%s]'%i.name)
        return '房子的名称是[%s],占地面积为[%d]平方米,剩余面积为[%d]平方米'%(self.name,self.area,self.free_area)

bed = Furniture('豪华双人大床',10)
print(bed)

home = House('小😀 的窝',150)
print(home)
print('='*80)
home.add_furniture(bed)
print(home)


        
    
